﻿using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Renren.Models;
using Renren.Helpers;
using Renren.ServiceProviders;

namespace Renren.Services
{
    public static class StatusService
    {
        public static void PublishStatusOld(string status)
        {
            var parameters = new Dictionary<string, string>();
            parameters.Add("method", "status.set");
            parameters.Add("status", status);
            Service.SendRequest(parameters, null);
        }

        public static void PublishStatus(string status, Action callback = null)
        {
            var parameters = new Dictionary<string, string>();
            parameters.Add("method", "status.set");
            parameters.Add("status", status);
            Service.SendRequest(
                parameters,
                result =>
                {
                    var code = XElement.Parse(result).Value;
                    if (code == "1")
                    {
                        if (callback != null)
                        {
                            callback();
                        }
                    }
                    else
                    {
                        ServiceProvider.NotifyResponseError(code, "发送状态失败");
                    }
                });
        }
    }
}
